#!/bin/sh

# 首先拷贝该文件到库目录下，修改脚本内的路径，在执行脚本
BuildType=$1
printf 'BuildType=%s\n' $BuildType

FinalBuildType=' '
if [[ $BuildType == 'Release' ]]
then
    FinalBuildType='Release'
else
    FinalBuildType='Debug'
fi
printf 'FinalBuildType=%s\n' $FinalBuildType

if [[ $FinalBuildType == 'Debug' ]]
then
    # Debug
    install_name_tool -change /usr/local/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib libPocoCryptod.95.dylib
    install_name_tool -change /usr/local/lib/libssl.3.dylib @rpath/libssl.3.dylib libPocoCryptod.95.dylib

    install_name_tool -change /usr/local/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib libPocoNetSSLd.95.dylib
    install_name_tool -change /usr/local/lib/libssl.3.dylib @rpath/libssl.3.dylib libPocoNetSSLd.95.dylib

    install_name_tool -change /usr/local/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib libPocoJWTd.95.dylib
    install_name_tool -change /usr/local/lib/libssl.3.dylib @rpath/libssl.3.dylib libPocoJWTd.95.dylib
else
    # Release
    install_name_tool -change /usr/local/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib libPocoCrypto.95.dylib
    install_name_tool -change /usr/local/lib/libssl.3.dylib @rpath/libssl.3.dylib libPocoCrypto.95.dylib

    install_name_tool -change /usr/local/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib libPocoNetSSL.95.dylib
    install_name_tool -change /usr/local/lib/libssl.3.dylib @rpath/libssl.3.dylib libPocoNetSSL.95.dylib

    install_name_tool -change /usr/local/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib libPocoJWT.95.dylib
    install_name_tool -change /usr/local/lib/libssl.3.dylib @rpath/libssl.3.dylib libPocoJWT.95.dylib
fi
